package action;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;

import com.alibaba.fastjson.JSON;
import com.opensymphony.xwork2.ActionSupport;
@ParentPackage("basePackage")
@Namespace("/")
public class BaseAction extends ActionSupport{
public String writeJson(Object object){
	try{
		String json=JSON.toJSONStringWithDateFormat(object,"yyyy-MM-dd HH:mm:ss");
		ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
		ServletActionContext.getResponse().getWriter().write(json);
		ServletActionContext.getResponse().getWriter().flush();
		ServletActionContext.getResponse().getWriter().close();
	}catch(IOException e){
		e.printStackTrace();
	}
	return null;

}
public HttpServletRequest getRequest() {
	return ServletActionContext.getRequest();
}
public HttpServletResponse getResponse() {
	return ServletActionContext.getResponse();
}
public HttpSession getSession() {
	return ServletActionContext.getRequest().getSession();
}
}
